package com.smartstate.dataManagement.controller;


import com.smartstate.dataManagement.entity.Team;
import com.smartstate.dataManagement.service.impl.TeamServiceImpl;
import com.smartstate.dataManagement.util.StringUtils;
import com.smartstate.dataManagement.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = {"班组配置管理器"})
@RequestMapping("/team")
@Slf4j
public class TeamController {
    @Autowired
    TeamServiceImpl teamService;


    @PostMapping("/getTeamByType")
    @ApiOperation(value = "根据班组类型获取相关信息(1是班组1，2 是班组2)")
    public ResultVO<List<Team>> getTeamByType(@RequestBody Team  team) {
        if(null!=team && StringUtils.isNotBlank(team.getTeamType())){
            return ResultVO.ok(teamService.getTeamByType(team));
        }
        return ResultVO.fail("参数缺失，请求失败");
    }


    @PostMapping("/addTeam")
    @ApiOperation(value = "新增或更新班组信息")
    public ResultVO<String> addTeam(@RequestBody List<Team> list) {
        return teamService.addTeam(list);
    }


    @GetMapping("/getTeam")
    @ApiOperation(value = "获取班组")
    public ResultVO<List<Team>> getTeam() {
        return ResultVO.ok(teamService.getTeam());
    }

}
